package com.ynet.eq.haiqing.module.mqtt.impl.datatran;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ynet.eq.haiqing.common.utils.SpringUtil;
import com.ynet.eq.haiqing.module.datatran.req.QueryUserReq;
import com.ynet.eq.haiqing.module.datatran.service.DataTranService;
import com.ynet.eq.haiqing.module.mqtt.MqttMessageStrategy;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.stereotype.Service;

/**
 * @author 胡超雄
 * @date 2021/7/1 16:57
 * @desc 4.1 增加和修改人员名单接口  返回消息的策略处理类
 */
@Service
public class MqttMessageEditPerson extends MqttMessageStrategy {


    @Override
    public void processMessage(String s, MqttMessage message) {

        String mess = new String(message.getPayload());
        System.out.println("先去查询用户的信息:" + mess);
        JSONObject messJsonObj = JSON.parseObject(mess);
        JSONObject info = messJsonObj.getJSONObject("info");
        //调用 查询信息的接口
        QueryUserReq req = new QueryUserReq();
        req.setId(info.getString("facesluiceId"));
        req.setCustomId(info.getString("customId"));
        System.out.println("查询人员入参:" + JSON.toJSONString(req));
        DataTranService dataTranService = SpringUtil.getBean(DataTranService.class);
        dataTranService.queryUser(req);

    }
}
